package com.itboye.hutouben.activity.qianbao;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.itboye.hutouben.R;
import com.itboye.hutouben.base.BaseActivity;
import com.itboye.hutouben.presenter.SystemMessgeAPresenter;
import com.itboye.hutouben.util.ByAlert;
import com.itboye.hutouben.util.IsUtilUid;
import com.itboye.hutouben.util.OnPasswordInputFinish;
import com.itboye.hutouben.util.PasswordView;
import com.itboye.hutouben.volley.ResultEntity;

import java.util.Observable;
import java.util.Observer;

/**
 * 忘记原支付密码(2.填写支付密码)
 *
 */
public class WangJiZhiFuPassTwoActivity extends BaseActivity implements Observer{
    TextView add_shap_title_tv,add_lift_tv;
    ImageView close_icon;
    SystemMessgeAPresenter presenter;
    PasswordView pwdView;// 支付密码

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_wang_ji_zhi_fu_pass_three);
        add_shap_title_tv.setVisibility(View.GONE);
        add_lift_tv.setText(R.string.chongzhi_zhifu_pass);
        presenter=new SystemMessgeAPresenter(this);
        final PasswordView pwdView = (PasswordView) findViewById(R.id.pwd_view);

        // 添加密码输入完成的响应
        pwdView.setOnFinishInput(new OnPasswordInputFinish() {
            @Override
            public void inputFinish() {
                // 输入完成后跳转
                // 也就是说——>实现你的交易逻辑什么的在这里写
                String pwd=pwdView.getStrPassword();
                presenter.onWallet(IsUtilUid.isUid(),pwd);

            }
        });
    }

    @Override
    protected void onInit() {



    }

    @Override
    protected void onReadIntent(Bundle bundle) {

    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.close_icon:
                finish();
                break;

            default:
                break;
        }
    }

    @Override
    public void update(Observable observable, Object data) {
        ResultEntity entity = handlerError(data);
        if (entity != null) {
            IsUtilUid.tianjia(entity);
            if (entity.getEventType() == presenter.Wallet_success) {
                ByAlert.alert(entity.getData()+"");
                finish();
                Intent sendIntent=new Intent("Wallet");
                sendBroadcast(sendIntent);
            }
        }
    }
}
